<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title><?php echo $_GET['goods']?>详情页</title>
		<link href="css/details.css" type="text/css" rel="stylesheet">
	</head>
	<body>
		<?php 
			require("/include/menu.php");		//导入头部
			include("../public/config.php");	//导入数据库配置文件
			date_default_timezone_set("PRC");
			$link = @mysqli_connect(HOST,USER,PASS,DBNAME) or die("数据库连接失败！");//连接数据库
			mysqli_set_charset($link,"utf8");	//设置数据库编码
		?>
			<!-- 网页主体开始 -->
			<div class="container">
				<div class="details_name">
				
				 	<!-- 输出面包屑导航 -->
					<a href="index.php">首页</a>  >&nbsp; 正文			
				</div>
				<div class="newConnect" style="width: 800px; margin-top: 20px;">
					<div class="newTitle" style="font-size: 24px;color:#404040">
						<p style="font-family: 微软雅黑">
							<?php
								$id = $_GET['id'];
								// $flag = true;
								//获取第一篇的ID号
								$sql = "select * from news order by id ";
								$res = mysqli_query($link,$sql);
								$news = mysqli_fetch_assoc($res);
								$minID = $news['id'];
								//获取最后一篇的ID号
								$sql = "select * from news order by id desc";
								$res = mysqli_query($link,$sql);
								$news = mysqli_fetch_assoc($res);
								$maxID = $news['id'];

								if($_GET['id']<$minID){
									$_GET=$minID;
									echo '<script>alert("已经是第一篇！"); </script>';
								}
								if($_GET['id']>$maxID){
									$_GET['id']=$maxID;
									echo '<script>alert("已经是最后一篇！"); </script>';
								}

								$sql = "select * from news where id=".$id;
								$res = mysqli_query($link,$sql);

/*								if ($news = mysqli_fetch_assoc($res)) {
									echo $news['name'];
								}else{
									$sql = "select * from news order by id ";
									$res = mysqli_query($link,$sql);
									$news = mysqli_fetch_assoc($res);
									$_GET['id'] = $news['id'];
									echo $news['name'];
								}*/
								
							?>
						</p>
						<p style="font-size: 14px;margin: 10px 0 20px;">
							<?php
								echo date("Y-m-d H:i:s",$news['addtime']);
								echo "<span style='display:inline-block;margin-left:30px;'>来源：{$news['ly']}</span>";
							?>
						</p>
					</div>
					<div class="connect" style="height: 500px;">
						<?php
							echo "<span style=\"font-size:18px;\">{$news['connect']}</span>";
						?>
					</div>
					<div>
						<?php
							echo '<a href="news.php?id='.($_GET['id']-1).'">上一篇</a>';
							echo '<a href="news.php?id='.($_GET['id']+1).'">下一篇</a>';
						?>
						
					</div>
				</div>
			</div>
			
			<div class="clear"></div>
			<div class="container">
			<?php include("./include/webbottom.php");?>
			</div>
	</body>
</html>